//
//  OMCreateOederView.m
//  XTCloud
//
//  Created by 孙海琛 on 2019/3/14.
//  Copyright © 2019 ShangHai HaoLei Software Technology Co., Ltd. All rights reserved.
//

#import "OMCreateOederView.h"
@interface OMCreateOederView()
@property (weak, nonatomic) IBOutlet UIView *mianView;
@property (weak, nonatomic) IBOutlet UIButton *btn1;
@property (weak, nonatomic) IBOutlet UIButton *btn2;
@property (weak, nonatomic) IBOutlet UIButton *btn3;
@property (weak, nonatomic) IBOutlet UIButton *btn4;


@end

@implementation OMCreateOederView

- (void)awakeFromNib
{
    [super awakeFromNib];
    self.backgroundColor = [UIColor colorWithWhite:0.f alpha:0.5];
    //设置圆角边框
    
    _mianView.layer.cornerRadius = 10;
    
    _mianView.layer.masksToBounds = YES;
}
- (void)updateUI:(NSDictionary *)dic
{
//    _dicM = dic;
    if ([dic[@"细石"] isEqualToString:@"1"]) {
        _btn1.selected = YES;
    }else
    {
        _btn1.selected = NO;
    }
    if ([dic[@"早强"] isEqualToString:@"1"]) {
        _btn2.selected = YES;
    }else
    {
        _btn2.selected = NO;
    }
    if ([dic[@"路面"] isEqualToString:@"1"]) {
        _btn3.selected = YES;
    }else
    {
        _btn3.selected = NO;
    }
    if ([dic[@"自密实"] isEqualToString:@"1"]) {
        _btn4.selected = YES;
    }else
    {
        _btn4.selected = NO;
    }
    _dicM = [NSMutableDictionary dictionary];
    [_dicM addEntriesFromDictionary:dic];
}
- (IBAction)okBtnAction:(UIButton *)sender {
    if (self.delegate && [self.delegate respondsToSelector:@selector(omcreateOederViewDelegate:)]) {
        if (sender.tag == 100) {
            [self.delegate omcreateOederViewDelegate:[NSMutableDictionary dictionary]];
        }else
        {
            [self.delegate omcreateOederViewDelegate:self.dicM];
        }
    }
}
- (IBAction)selectBtnAction:(UIButton *)sender {
    
    if (sender.tag == 1000) {
        if (sender.selected == NO) {
            [self.dicM setObject:@"1" forKey:@"细石"];
            _btn1.selected = YES;
        }else
        {
            [self.dicM setObject:@"0" forKey:@"细石"];
            _btn1.selected = NO;
        }
    }else if (sender.tag == 1001)
    {
        if (sender.selected == NO) {
            [self.dicM setObject:@"1" forKey:@"早强"];
            _btn2.selected = YES;
        }else
        {
            [self.dicM setObject:@"0" forKey:@"早强"];
            _btn2.selected = NO;
        }
    }else if (sender.tag == 1002)
    {
        if (sender.selected == NO) {
            [self.dicM setObject:@"1" forKey:@"路面"];
            _btn3.selected = YES;
        }else
        {
            [self.dicM setObject:@"0" forKey:@"路面"];
            _btn3.selected = NO;
        }
    }else if (sender.tag == 1003)
    {
        if (sender.selected == NO) {
            [self.dicM setObject:@"1" forKey:@"自密实"];
            _btn4.selected = YES;
        }else
        {
            [self.dicM setObject:@"0" forKey:@"自密实"];
            _btn4.selected = NO;
        }
    }
}
//- (NSMutableDictionary *)dicM
//{
//    if (!_dicM) {
//        _dicM = [NSMutableDictionary dictionary];
////        [_dicM setObject:@"0" forKey:@"细石"];
////        [_dicM setObject:@"0" forKey:@"早强"];
////        [_dicM setObject:@"0" forKey:@"路面"];
////        [_dicM setObject:@"0" forKey:@"自密实"];
//    }
//    return _dicM;
//}

@end
